<script type="text/javascript" language="javascript">
    (function($) {
        /*whatever jQuery stuff*/
        $(function(){	
			//SimpleDate Picker		
			$('.datetime').simpleDatepicker({ startdate: 1900, enddate: new Date().getFullYear() });	
        });
    })(jQuery);	
</script>
<div class="wrap">
 	<div id="icon-index" class="icon32"><br /></div><h2><?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?></h2>
</div>
<div id="wpbody-content">
    <div class="metabox-holder" id="dashboard-widgets">
            <div class="inside">
				<div id="filter_panel">
					<form action="<?php echo current_url();?>" method="get" name="SearchForm" id="SearchForm">
					<ul>
						<li>
							<span>Start Date :</span>
							<input type="text" name="start_date" id="start_date" class="medium-text datetime" value="<?php echo ($this->input->get('start_date') != '' ? $this->input->get('start_date'):'');?>" readonly="readonly"/>
						</li>
						<li>
							<span>End Date :</span>
							<input type="text" name="end_date" id="end_date" class="medium-text datetime" value="<?php echo ($this->input->get('end_date') != '' ? $this->input->get('end_date'):'');?>" readonly="readonly"/>
						</li>
						<li>
							<span><?php echo lang('media_type');?> :</span>
							<select name="media_type_id" id="media_type_id">
								<option value=""><?php echo lang('select_option');?></option>
								<?php if(!empty($dataMediaType)) foreach($dataMediaType as $value):?>
									<option value="<?php echo $value->media_type_id;?>" <?php echo (@$this->input->get('media_type_id') == $value->media_type_id ? 'selected="selected"':'');?>><?php echo $value->media_type_name;?></option>
								<?php endforeach;?>
							</select>
						</li>																	
					</ul>
					<br />
					&nbsp;&nbsp;<input type="submit" value="<?php echo lang('button_search');?>" class="button-primary"/>
					<input type="reset" value="<?php echo lang('button_reset');?>" class="button-primary"/>
					</form>
				</div>
				<div class="tablenav top">
					<p class="search-box">
						<input type="button" onclick="javascript:toggleFilter(this);" class="button-primary" value="<?php echo lang('button_filter');?>" />
					</p>
				</div>		
				<form action="<?php echo current_url();?>/delete" method="post" name="ListForm" id="ListForm">
				<table cellspacing="0" class="wp-list-table widefat fixed">
					<thead>
					<tr>
						<?php 
							echo generate_th_orderby(array(
								array(
									'name' => lang('song_id'),
									'width' => 60
								),
								array(
									'name' => 'Song Name'
								),
								array(
									'name' => 'Artist Name'
								),
								array(
									'name' => 'Views',
									'width' => 80
								),																
								array(
									'name' => 'Create Date'	
								),																
								array(
									'name' => 'Update Date'	
								)
							));
						?>
					</tr>
					</thead>
				
					<tfoot>
					<tr>
						<?php 
							echo generate_th_orderby(array(
								array(
									'name' => lang('song_id'),
									'orderby' => 'song_id',
									'width' => 60
								),
								array(
									'name' => 'Song Name'
								),
								array(
									'name' => 'Artist Name'
								),
								array(
									'name' => 'Views',
									'width' => 80
								),
								array(
									'name' => 'Create Date'	
								),																						
								array(
									'name' => 'Update Date'	
								)
							));
						?>
					</tr>
					</tfoot>
				
					<tbody>
						<?php
						if(!empty($dataResult)):
							foreach($dataResult as $value):
						?>
							<tr>
								<td class=""><?php echo sprintf('%06d',$value->song_id);?></td>
								<td class=""><?php echo $value->song_name;?></td>
								<td class="">
									<?php foreach($value->artist as $key => $artist):?>
										<?php echo ($key==0 ? '':'/');?>
										<?php echo $artist->artist_name;?>
									<?php endforeach;?>
								</td>
								<td class=""><?php echo $value->views;?></td>
								<td class=""><?php echo date('Y-m-d',strtotime($value->create_date));?></td>
								<td class=""><?php echo $value->update_date;?></td>
							</tr>
							<?php
							endforeach;
						else: //not exists
							?>
							<tr valign="middle" class="alternate"><td colspan="6"><?php echo lang('no_data');?></td></tr>			
						<?php
						endif;
						?>
					</tbody>
				</table>
				<div class="tablenav bottom"></div>				
				</form>
            </div><!-- wpbody inside -->
    </div><!-- wpcontent -->
</div><!-- wpbody-content -->